﻿#if NETCore
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Options;
#endif

namespace Longbow.Tasks
{
    /// <summary>
    /// 物理文件持久化配置类
    /// </summary>
    public class FileStorageOptions
    {
        /// <summary>
        /// 获得/设置 是否启用物理文件持久化 默认 true 启用
        /// </summary>
        public bool Enabled { get; set; } = true;

        /// <summary>
        /// 获得/设置 物理文件持久化文件目录名称 默认 TaskStorage
        /// </summary>
        public string Folder { get; set; } = "TaskStorage";

        /// <summary>
        /// 获得/设置 是否对持久化文件加密 默认为 true
        /// </summary>
        public bool Secure { get; set; } = true;

        /// <summary>
        /// 获得/设置 加密解密密钥
        /// </summary>
        public string Key { get; set; } = "LIBSFjql+0qPjAjBaQYQ9Ka2oWkzR1j6";

        /// <summary>
        /// 获得/设置 加密解密向量值
        /// </summary>
        public string IV { get; set; } = "rNWuCRQAWjI=";

        /// <summary>
        /// 获得/设置 任务被移除时是否删除持久化文件
        /// </summary>
        public bool DeleteFileByRemoveEvent { get; set; } = true;
    }
#if NETCore
    /// <summary>
    /// 缓存配置类
    /// </summary>
    /// <typeparam name="TOptions"></typeparam>
    internal class FileStorageOptionsConfigureOptions<TOptions> : ConfigureFromConfigurationOptions<TOptions> where TOptions : class
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="configuration"></param>
        public FileStorageOptionsConfigureOptions(IConfiguration configuration)
            : base(configuration.GetSection("FileStorageOptions"))
        {

        }
    }
#endif
}
